<?php
//include dirname(__FILE__).'/../conf/conf.php';
require_once (dirname(__FILE__)."/../lib/YopClient3.php");

function object_array($array) { 
    if(is_object($array)) { 
        $array = (array)$array; 
     } if(is_array($array)) { 
         foreach($array as $key=>$value) { 
             $array[$key] = object_array($value); 
             } 
     } 
     return $array; 
}



function register(){

#易宝公钥   不用改 ！ 不用改 ！ 不用改 ！
    $yop_public_key  = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxHkdi6Wm0eGe5BeVvGPjzUTNPjsTrovyM0YmWg33ao25y/tXWKuIcDN2K6lDb/u1gOlWmsWsutdQpJ0UJ7DSoEvzJNC/i8FYjrw7JAJww7ivhbj0UlQYdJoeYzwlp8g2gggQp3xhbCOJGzLRj4uz4ENRHROPPCLkC5YLIjWknEIbHKdwyi5exz+GV6sp+2LpNi+l/TKmHf44zBP011YTW3WMbKg+4FpSbkVvKaD+be3vVGDht68Ss9FVoGOwei4NRbCYEW/PEznp1YXFIw2e/huVShzRwoZZZ/4zLgs14eKLWUN/2lFClNyJrZDJNsKz6Kw9QOwEjKy55wWFHHS+dQIDAQAB";
#商户私钥
//    $private_key ="MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCjJgBQLiN2tr2N9vv+uw5EU7PtZPGHXrgC67BvAxaujUiAjD5G4xnyLKeXzBcgdChgpbopYzLAlEiCp88dvWtZ4cyjCdMBz/nHaWv7uy6qc75jeS6fjiDLXxNfK09A0+mKdAl1QuBNAjaBkNwr9GHXjf9kSQBx/vZAXX3D4EZrtr07DU3r78q7IorEIbOIRbQFa/NMUUrrkn2Kvx62B43Q9PFnla+it0GL9Rr2b8f4Z/0gj4KY5k15Jv5CICGYetsNenIYaWqExAhY0g6M5dc4YPgXPZi2lDS0wtV4g78g4RyXpre82guSuvQ0pGrHuMoRigftSUm/fmBh/8Scx5HvAgMBAAECggEAL4PuzWtSms2IEWOgasTx18aE/ZvLmEBm2TrpbLt6jKXLOt0deinE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KzXllXenchcnWTvZfLgOB2vdAIYRTpRy1JmPlVgsgvQ5JMInrV4D8+Ikrov9I9xfL0V79gK84+Uo2iFOm+DfMXrienXx+tzXPYu+ciFJelMFfBckUeXndl3nJPUD4+11heQbPcX/05RdTjop6+PAoGBAKQtbp9pot7ctKdBZSZ3F89FB5IHE9ebBY4tEJ6ggofu9lxjJXAXsfj3UI2bDDe30IykdONiNfFEdamBFLTawY/FFxgRPe1uNXM8pN8Q7d/rt9GdnDddqNK8Kf92xR7RAY1rYzKpnUTJU369mtFy/jQNt67UudxuFdugQ120JJoVAoGBAMC5qT0AVJDYcpmVKV9MA98OUBEzpoyh/HG+/G4Imu7TAGKHnlzHRNdEZnQg9bLQWn850ovej5nOTfq9SpOGP+kjJ4U5CFHp3R2lJAlvxfZgPIa75Cssc87nKN5htR9BvC2gj5p8P+gWZzj3qrr0Q6qy4auMFSGIGxMQEuinDSyrAoGAaybvo7vcnBQ3jZXstuEs+ltvhCeWU25obsc/H6FzOlrr5zD3r5BPGGVn9/+C5+9HV2myWsfQirjaq6P6/rNuatstukAe2JRo1snAFtAX+UNwSMeai+hongnd4Dcvk62KWhSYqe+VkgdHq5+JBYdrh0DEzc116qjjnaWW3c132H4=';

    $request = new YopRequest($merchantNo, $private_key, "https://open.yeepay.com/yop-center",$yop_public_key);
     
    

	 $request->addParam("requestNo", $_REQUEST['requestNo']);
	 $request->addParam("merchantUserId", $_REQUEST['merchantUserId']);
	 
	
    $response = YopClient3::post("/rest/v1.0/payplus/user/register", $request);
	 // var_dump($response);
    if($response->validSign==1){
        echo "返回结果签名验证成功!\n";
    }
    //取得返回结果
    $data=object_array($response);

    return $data;
    
 }
  $array=register();  
  
 if( $array['result'] == NULL)
 {
 	echo "error:".$array['error'];
  return;}
 else{
 $result= $array['result'] ;
  // var_dump($result);
}
?> 


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户注册结果</title>
</head>
	<body>	
		<br /> <br />
		<table width="70%" border="0" align="center" cellpadding="5" cellspacing="0" style="border:solid 1px #107929">
			<tr>
		  		<th align="center" height="30" colspan="5" bgcolor="#6BBE18">
					用户注册结果
				</th>
		  	</tr>

				<tr >
				<td width="25%" align="left">&nbsp;返回码</td>
				<td width="5%"  align="center"> : </td> 
				<td width="45"  align="left"> <?php echo $result['code'];?> </td>
				<td width="5%"  align="center"> - </td> 
				<td width="30%" align="left">code</td> 
			</tr>

			<tr>
				<td width="25%" align="left">&nbsp;返回信息</td>
				<td width="5%"  align="center"> : </td> 
				<td width="35%" align="left"> <?php echo $result['message'];?> </td>
				<td width="5%"  align="center"> - </td> 
				<td width="30%" align="left">message</td> 
			</tr>

				<tr >
				<td width="25%" align="left">&nbsp;用户编号</td>
				<td width="5%"  align="center"> : </td> 
				<td width="45"  align="left"> <?php echo $result['memberNo'] ;?>  </td>
				 
				 
			</tr>
			 
 

		</table>

	</body>
</html>